package com.iot08.api.service;

import com.aliyun.tea.utils.StringUtils;
import com.iot08.common.entity.app.LoginOperateLog;
import com.iot08.common.service.base.BaseAdminService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;


/**
 * @author cwj
 * @description
 * @date 2025/2/22 11:01
 **/
@Slf4j
@Service
public class LoginOperateLogService extends BaseAdminService<LoginOperateLog> {


    /**
     * @description 保存注册、登录、登出、注销等操作的操作日志
     * @author cwj
     * @param [openid, loginWay, opreateType, opreateName, opreateStatus, param, methodNamme, desc]
     * @return void
     * @date @time 2025/2/22 11:06
     **/
    public void saveLoginOpeateLog(String openid,String name,String phone,String loginWay,Integer opreateType,
                                   String opreateName,Integer opreateStatus,String param,String methodNamme,String desc){
        LoginOperateLog loginOperateLog = new LoginOperateLog();
        if(!StringUtils.isEmpty(openid)){
            loginOperateLog.setOpenid(openid);
        }
        if(!StringUtils.isEmpty(name)){
            loginOperateLog.setName(name);
        }
        if(!StringUtils.isEmpty(phone)){
            loginOperateLog.setPhone(phone);
        }
        if(!StringUtils.isEmpty(loginWay)){
            loginOperateLog.setLoginWay(loginWay);
        }
        loginOperateLog.setOpreateType(opreateType);
        loginOperateLog.setOpreateName(opreateName);
        loginOperateLog.setOpreateStatus(opreateStatus);
        if(!StringUtils.isEmpty(param)){
            loginOperateLog.setParam(param);
        }
        loginOperateLog.setMethodName(methodNamme);
        loginOperateLog.setDesc(desc);
        loginOperateLog.setCreateTime(new Date());
        this.save(loginOperateLog);
    }
}
